/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * Description:
 * Author: huawei
 * Create: 2022-11-29
 */
#ifndef SVM_RBTREE_H
#define SVM_RBTREE_H

#include <linux/rbtree.h>

typedef u64 (*rb_handle_func)(struct rb_node *node);
typedef bool (*rb_erase_condition)(struct rb_node *node);

int devmm_rb_erase(struct rb_root *root, struct rb_node *node);
int devmm_rb_insert(struct rb_root *root, struct rb_node *node, rb_handle_func get_handle);
struct rb_node *devmm_rb_search(struct rb_root *root, u64 handle, rb_handle_func get_handle);

struct rb_node *devmm_rb_erase_one_node(struct rb_root *root, rb_erase_condition condition);

#endif /* SVM_RBTREE_H */
